<?php

namespace app\mall\controller\api\store;

use app\mall\enum\StatusEnum;
use app\mall\exceptions\ApiException;
use app\mall\model\MallGoods;
use app\mall\model\MallStore;

class Info extends Base
{

    /**
     * @return \think\response\Json
     * @throws \app\mall\exceptions\BaseException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        $id = $this->request->get('id');
        if (!$id) {
            ApiException::throws(ApiException::$requireArgs);
        }
        $model = MallStore::where('status', StatusEnum::VALID)
            ->field(['id', 'logo', 'address', 'business_hours', 'region_names', 'phone']);
        $info = $model->find($id);
        if (!$info) {
            ApiException::throws(ApiException::$infoNotFound);
        }
        return json_return($info);
    }

}